package com.jch.helloworld.configBeans.autowire;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestAutoWireBean {

    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("/beans/AutowireBean.xml");
        System.out.println("默认自动装配方式：");
        Person person0 = (Person) ctx.getBean("person3");
        System.out.println(person0);
        System.out.println("根据setter方法名称自动装配：");
        Person person = (Person) ctx.getBean("person");
        System.out.println(person);
        System.out.println("根据属性类型自动装配：");
        Person person1 = (Person) ctx.getBean("person1");
        System.out.println(person1);
        System.out.println("根据构造器自动装配：");
        Person person2 = (Person) ctx.getBean("person2");
        System.out.println(person2);
    }

}
